package com.codeworker.asyncrequestresenddemo.controller;

import com.codeworker.asyncrequestresenddemo.service.LocalService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalTime;

/**
 * Description: 控制层
 *
 * @author code-worker
 * @date 2021/10/14 20:14
 */
@RestController
public class AsyncController {

    @Resource
    private LocalService localService;

    /**
     * task: 异步请求测试
     * @author code-worker
     * @date 2021/10/15 9:48
     * @param num 参数
     * @return java.lang.String
     */
    @GetMapping("async")
    public String askAsync(int num){
        System.out.println("AsyncController | askAsync | thread: " + Thread.currentThread().getName() + ", time: " + LocalTime.now());
        localService.askAsyncManager(num);
        System.out.println("AsyncController | askAsync | return res, time: " + LocalTime.now());
        return "success";
    }

}
